
function(group_files next_directory result)

    get_filename_component(_curname ${next_directory} NAME )
    #message(STATUS "current: ${next_directory} " )
    #message(STATUS "current: ${_curname} " )

    if(NOT IS_ABSOLUTE ${next_directory} )
        message(FATAL_ERROR "in function 'group_files' expected that the '${next_directory}' - it is a real directory" )
    endif()

    set(_files)
    set(_folders)
    info_dir( _folders _files ${next_directory} )

    if(_curname STREQUAL "include" OR _curname STREQUAL "src" OR _curname STREQUAL ${PROJECT_NAME} )
        source_group(\\ FILES ${_files} )        
    else()
        source_group(${_curname}\\ FILES ${_files} )
    endif()

    set(coll )
    foreach( _unit ${_folders} )
        if(NOT _unit MATCHES "ignor*." )
            group_files( ${_unit} coll )
            list(APPEND _files ${coll} )
        endif()
    endforeach()

    set(${result} ${${result}} ${_files} PARENT_SCOPE)

endfunction()

